// glotech_ele400_clarity.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "glotech_headers.h"


void test_functions(const int TO_TEST){
	QUEUE * q;
	NODE * n;
	MODEL * m;
	int cnt = 0;
	float num = 100;

	printf("Entering test function...\n");
	switch(TO_TEST){
		case 0:
			printf("Testing queue data structure...\n");
			printf("Testing queue initialisation\n");


			q = init_queue();
			if(q == NULL){
				printf("NULL Value received from init_queue(), exiting testing\n");
				break;
			}
			system("pause");
			printf("\nTesting push function... ");
			while(cnt != 5){
				("Pushing... ");
				if(push(q, num,num,num,num,num,num)){
					printf("Unable to add node... exiting\n");
					destroy_queue(q);
				}
				cnt++;
				num++;
				print_queue(q);
				system("pause");
			}
			system("pause");
			printf("\nPrinting queue...\n");
			print_queue(q);
			system("pause");
			printf("\nTesting pop()\n");
			n = pop(q);
			print_node(n);
			print_queue(q);
			system("pause");
			printf("Destroying queue...\n");
			destroy_queue(q);
			printf("Done!! :D \n");
			system("pause");
			break;
		case 1:
			printf("Testing model dataset\n");
			printf("Testing model initialisation\n");
			m = init_model();
			if(m == NULL){
				printf("NULL received from init_model(), quitting...\n");
				break;
			}
			printf("Generating random data for expert queue\n");
			cnt = 0;
			while(cnt < 4){
				push(m->q_expert, num,num,num,num,num,num);
				num++;
				cnt++;
			}
			printf("Generating random data for tech queue\n");
			cnt = 0;
			while(cnt < 7){
				push(m->q_technician, num,num,num,num,num,num);
				num++;
				cnt++;
			}

			printf("Printing expert queue\n");
			print_queue(m->q_expert);
			system("pause");
			printf("Printing tech queue\n");
			print_queue(m->q_technician);
			system("pause");

			printf("Destroying Model...\n");
			destroy_model(m);
			printf("Model: 0x%x\n",m);
			system("pause");

			break;
		case 2:
			printf("Testing basic graphics...\n");
			printf("Testing graphics initialisation\n");
			//init_graphics();
			system("pause");
			printf("Destroying graphics\n");
			//destroy_graph();
			system("pause");
		default:
			printf("Nothing was defined\n");
			break;
	}
	printf("Exiting test functions...\n");
}

void init_random(void){
	srand(time(NULL));
}

int main(int argc, char **argv)
{
	int TEST = 1;
	int TO_TEST = 0;
	init_random();


	if(TEST == 1){
		printf("What do you wish to test?\n");
		printf("0 - Data structure tests\n");
		printf("1 - Data model tests\n");
		printf("2 - Basic graph tests\n");
		printf("99 - Exit\n");
		scanf("%i", &TO_TEST);
		if(TO_TEST != 99)
			test_functions(TO_TEST);
	}

	system("pause");

	return 0;
}

